/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package sv.com.globalsolutionslt.controlador;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import sv.com.globalsolutionslt.entidades.Rubro;

/**
 *
 * @author karinaMelara
 */
@Stateless
public class RubroFacade extends AbstractFacade<Rubro> {
    @PersistenceContext(unitName = "BoldeDeTrabajoPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public RubroFacade() {
        super(Rubro.class);
    }
    
    
     public List<Rubro> bRubroPer(Integer i) {
        List<Rubro> rubro=null;
        try {        
        String sql = "SELECT r FROM Rubro r  WHERE r.idTipoRubro.idTipoRubro="+i+" and r.activo="+true;
        Query q = em.createQuery(sql);
        rubro = q.getResultList();
        
        } catch (NoResultException e) {
                System.out.println("Sin resultados");
        }
        return rubro;
    }    
    
}
